<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>后台管理——车讯查询</title>

    <!-- Bootstrap core CSS -->
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
    <link th:href="@{/css/backstage_index.css}" rel="stylesheet"/>
</head>

<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
        <div class="navbar-header">
            <a href="#">汽车购票后台管理</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse manage navbar-right">
            <ul class="nav navbar-nav">
                <li class="actives"><a th:href="@{/ticket/index}">车讯管理</a></li>
                <li><a th:href="@{/customer/index}">用户管理</a></li>
            </ul>
            <div class="user">
                <a href="#">admin</a>
                <a href="#" th:href="@{/admin/login}">注销</a>
            </div>
        </div>
    </div>
</nav>

<div class="container-fluid" id="container-fluid">
    <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
            <ul class="nav">
                <li><a th:href="@{/ticket/index}">车讯列表</a></li>
                <li><a th:href="@{/ticket/query}">车讯查询</a></li>
                <li class="active"><a th:href="@{/ticket/notice}">车讯公告</a></li>
            </ul>
        </div>
        <div class="col-md-10 col-md-offset-2 main">
            <a id="shownotice" class="btn btn-primary btn-block">添加+</a>
            <div id="notice" class="notice form-inline" style="display: none;"><!--  -->
                <h2>公告</h2>
                <form th:action="@{/ticket/notice}" method="post">
                    <label>标题：<input type="text"id="title" name="title" class="form-control" autofocus/></label>
                    <label>内容：
                        <textarea type="textarea" id="content" name="content" class="form-control" placeholder="请输入..." ></textarea>
                    </label>
                    <button id="puton" class="btn btn-primary btn-block" type="submit">发&nbsp;布</button>
                </form>
            </div>
            <div class="history" style="border-top: 3px solid #000;">
                <h2>历史公告</h2>
                <div class="connotice col-md-10 col-md-offset-1" id="hisdiv" th:each="item:${notice}">
                        <p  style="text-align: center; font-weight: bolder; font-size: 20px" th:text="${item.title}"> 公告标题</p>
                        <div>内容：<span th:text="${item.content}">公告内容</span></div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var btnshow = document.getElementById('shownotice');
    var notice = document.getElementById('notice');
    var btnhide = document.getElementById('puton');
    var hisy = document.getElementById('hisy');
    var in_title = document.getElementById('in_title');
    var in_context = document.getElementById('in_context');
    var notice_title = document.getElementById('notice_title');
    var notice_con = document.getElementById('notice_con');

    //------添加+按钮事件
    btnshow.onclick = function(){
        notice.style.display = "block";
        btnshow.style.display = "none";
        in_title.value = "";
        in_context.value ="";
    }
    //------发布按钮事件
    btnhide.onclick = function(){
        notice.style.display = "none";
        btnshow.style.display = "block";

        if(in_title.value != ""&&in_context.value!=""){
            var newdiv = document.createElement("div");
            hisy.appendChild(newdiv);
            newdiv.className = "connotice col-md-10 col-md-offset-1";
            var newnotice_title = document.createElement("p");
            var newnotice_con = document.createElement("div");
            newdiv.appendChild(newnotice_title);
            newdiv.appendChild(newnotice_con);
            newnotice_title.innerHTML ="标题："+ in_title.value;
            newnotice_con.innerHTML = "内容："+ in_context.value;
        }

    }

</script>
</body>
</html>
